package com.py.credit.utils;

import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;

import com.py.credit.common.logs.ExceptionLogger;
import com.py.credit.common.rest.RestServiceResult;
import com.py.credit.constant.ResourcePath;

public class ThreadExportCallable implements Callable<String> {
	
	
	private List<Map<String,String>> listE;
	
	private String pdfForXypjPagePathYz;
	
	private String pdfJsPath;
	
	private String absolutepath;
	
	private String googlePath;
	
	private String pch;
	
	private String pcId;
	
	public ThreadExportCallable(List<Map<String,String>> listE,String pdfForXypjPagePathYz,String pdfJsPath,
			String absolutepath,String googlePath,String pch,String pcId){
		this.listE=listE;
		this.pdfForXypjPagePathYz=pdfForXypjPagePathYz;
		this.pdfJsPath=pdfJsPath;
		this.absolutepath=absolutepath;
		this.googlePath=googlePath;
		this.pch=pch;
		this.pcId=pcId;
	}

	@Override
	public String call() throws Exception {
		for(int i=0;i<listE.size();i++){
			String url=pdfForXypjPagePathYz+"?tybm="+listE.get(i).get("tybm")+"&pcId="+pcId;
			boolean googleConvent = HtmlToPdfUtils.googleConventSync(pdfJsPath,
					url,
					absolutepath + ResourcePath.CREDIT_REPORT_DIR+pch,listE.get(i).get("mainName")+".pdf", null, false,
					googlePath);
			if(!googleConvent){
				return "-1";
			}
		}
		return "0";
	}

}
